﻿#region licence
//  Copyright 2008 Michael Cromwell

//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at

//       http://www.apache.org/licenses/LICENSE-2.0

//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using log4net.altconf;
using log4net.Core;
using NUnit.Framework.SyntaxHelpers;
using System.Reflection;
using log4net.Repository.Hierarchy;
using Rhino.Mocks;
using log4net.Repository;
using log4net.Util;

namespace log4net.altconf.Tests
{
    
    public class DslRepositorySpecification
    {
        protected DslRepository createSUT()
        {
            return new DslRepository();
        }
    }


    [TestFixture]
    public class When_dsl_repository_configuring_global_options : DslRepositorySpecification
    {

        [Test]
        public void Should_set_internal_debugging()
        {
            LogLog.InternalDebugging = false;
            var configStub = new TestLog4NetDslConfiguration();
            configStub.debug = true;
            var sut = createSUT();
            sut.Configure(configStub);
            Assert.That(LogLog.InternalDebugging, Is.True);
        }
        
        [Test]
        public void Should_set_threshold_level()
        {
            var configStub = new TestLog4NetDslConfiguration();
            configStub.threshold = Level.Fatal;
            var sut = createSUT();
            sut.Configure(configStub);
            Assert.That(sut.Threshold, Is.EqualTo(Level.Fatal));
        }
      
    }


    [TestFixture]
    public class When_dsl_repository_configuring_logs : DslRepositorySpecification
    {

        [Test]
        public void Should_add_log()
        {
            var configStub = new TestLog4NetDslConfiguration();
            configStub.LogFor("foo", () => { });
            var sut = createSUT();
            sut.Configure(configStub);
            Assert.That(sut.Exists("foo"), Is.Not.Null);
        }



    }
}
